﻿
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Script/jquery-3.3.1.min.js"></script>
    <script>
        function AddUser() {
                var userName = $('#userName').val();
                var userSex = $('#userSex').val();
            $.ajax({
                type: 'post',
                url: "@Url.Action("Add","Home")",
                data: { Name: userName, Sex: userSex },
                success: function (data) {
                    alert(data);
                    console.log(data);
                }
            });
        }
        function Get() {
             $.ajax({
                type: 'post',
                url: "@Url.Action("GetUser", "Home")",
              //  data: { Name: userName, Sex: userSex },
                success: function (data) {
                    alert(data);
                    console.log(data);
                }
            });
        }
        function GetArticle() {
             $.ajax({
                type: 'post',
                url: "@Url.Action("GetUserArticle", "Home")",
              //  data: { Name: userName, Sex: userSex },
                success: function (data) {
                    alert(data);
                    console.log(data);
                }
            });
        }
    </script>
</head>
<body>
    <div>
        姓名:<input id="userName" type="text" />
        <br />
        性别:<input id="userSex" type="text" />
        <br />
        <input type="button" id="btn" value="提交" onclick="AddUser()" />
        <br />
        <input type="button" id="btn2" value="获取用户" onclick="Get()" />
        <br />
        <input type="button" id="btn2" value="获取用户文章" onclick="GetArticle()" />
    </div>
</body>
</html>
